// pages/goods/classify/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    mainActiveIndex: 0,
    activeId: null,
    classifyList: []
  },

  onClickNav({
    detail = {}
  }) {
    this.setData({
      mainActiveIndex: detail.index || 0,
    });
  },

  onClickItem({
    detail = {}
  }) {
    const activeId = this.data.activeId === detail.catId ? null : detail.catId;
    wx.setStorageSync('catId', detail.catId)
    this.setData({
      activeId
    });
    setTimeout(() => {
      wx.navigateBack({
        delta: 1
      })
    }, 500)

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.getData()
  },

  getData() {
    const self = this;
    wx.request({
      url: 'https://erp.yilestar.com/weapp/shops/getShopCats',
      success(res) {
        console.log(res)
        const data = res.data.data;
        self.setData({
          classifyList: data
        })
      }
    })
  }
})